﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nanoCMS.Core.Providers;

namespace nanoCMS.Core.Test.Providers
{
    [TestClass]
    public class MessageProvider_Test
    {
        private readonly ContextBuilder contextBuilder = new ContextBuilder();
        private MessageProvider messageProvider;
        [TestInitialize]
        public void Init()
        {
            messageProvider = new MessageProvider(contextBuilder.Entities);
        }


        [TestMethod]
        public void Simple_Add_Message()
        {
            var guid = Guid.NewGuid().ToString();
            messageProvider.Add("Core",guid, "bla");
            Assert.IsNotNull(messageProvider.Get("Core",guid));
        }

        [TestMethod]
        public void Message_Add_GetProcessed()
        {
            var guid = Guid.NewGuid().ToString();
            messageProvider.Add("Core",guid, "Moje malo misto se zove {$Grad$}");
            Dictionary<string, string> bla = new Dictionary<string, string> {{"Grad", "Zagreb"}};

            Assert.AreEqual(messageProvider.GetProcessedMessage("Core",guid, bla).Content, "Moje malo misto se zove Zagreb");
        }
    }
}
